//
//  RedPointButton.m
//  QA
//
//  Created by 李小龙 on 2017/6/15.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "RedPointButton.h"

@implementation RedPointButton

+ (instancetype)buttonWithType:(UIButtonType)buttonType {
    RedPointButton *button = [super buttonWithType:buttonType];
    UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 6, 6)];
    [redView setBackgroundColor:[UIColor redColor]];
    [redView.layer setCornerRadius:3];
    [redView.layer setMasksToBounds:YES];
    [redView setTag:100];
    [redView setHidden:YES];
    [button addSubview:redView];
    [button bringSubviewToFront:redView];
    return button;
}

- (UIView *)redPoint {
    _redPoint = [self viewWithTag:100];
    return _redPoint;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    self.redPoint.mj_x = self.size.width-4;
    self.redPoint.mj_y = self.imageView.mj_y-2;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.redPoint.mj_x = self.size.width-4;
    self.redPoint.mj_y = self.imageView.mj_y-2;
}

@end
